# -*- coding: utf-8 -*-
"""
@Time：YourTime
@Author  : YourName
@Desc    : 
"""

import allure
from playwright.sync_api import Page, expect
from repository import logoutObject
from utils.configParse import ConfigParse


class LogoutPage:
    def __init__(self, page: Page):
        """
        定义封装页面对象
        :param page:
        """
        self.page = page
        self.login_head_portrait_loc = page.locator(logoutObject.login_head_portrait)
        self.logout_button_loc = page.locator(logoutObject.logout_button)
        self.logout_confirm_box_loc = page.locator(logoutObject.logout_confirm_box)
        self.logout_confirm_box_text_loc = page.locator(logoutObject.logout_confirm_box_text)
        self.logout_confirm_box_cancel_loc = page.locator(logoutObject.logout_confirm_box_cancel)
        self.logout_confirm_box_confirm_loc = page.locator(logoutObject.logout_confirm_box_confirm)

    @allure.step('退出xbase')
    def logout_xbase(self):
        # 鼠标移动到头像上面
        self.login_head_portrait_loc.hover()
        self.logout_button_loc.wait_for(state='visible')
        self.logout_button_loc.hover()
        self.logout_button_loc.click()
        self.logout_confirm_box_confirm_loc.wait_for(state='visible')
        expect(self.logout_confirm_box_text_loc).to_have_text('您确定要退出吗？')
        self.logout_confirm_box_confirm_loc.click()
        assert '登录X-Base' is not None
